package com.carreirati.evaluation;

import java.util.List;

import com.carreirati.evaluation.domain.AppraisalResults;
import com.carreirati.evaluation.domain.KnowledgeArea;
import com.carreirati.evaluation.domain.Profile;

import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.roo.addon.web.mvc.controller.json.RooWebJson;
import org.springframework.roo.addon.web.mvc.controller.scaffold.RooWebScaffold;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

@RequestMapping("/knowledgeareas")
@Controller
@RooWebScaffold(path = "knowledgeareas", formBackingObject = KnowledgeArea.class)
@RooWebJson(jsonObject = KnowledgeArea.class)
public class KnowledgeAreaController {
	
	@RequestMapping(value = "/findbyappraisal{appraisalId}", headers = "Accept=application/json")
    @ResponseBody
    public ResponseEntity<java.lang.String> findJson(@PathVariable("appraisalId") long appraisalId) {
        HttpHeaders headers = new HttpHeaders();
        headers.add("Content-Type", "application/json; charset=utf-8");
        List<KnowledgeArea> result = KnowledgeArea.fingAppraisalKnowledgeAreas(appraisalId);     
         return new ResponseEntity<String>(KnowledgeArea.toJsonArray(result), headers, HttpStatus.OK);
    }
	
	
	@RequestMapping(value = "/getselectedknowledgeareasbyprofile{profileId}", headers = "Accept=application/json")
    @ResponseBody
    public ResponseEntity<java.lang.String> findKnowledgeAreasByProfileJson(@PathVariable("profileId") String profileId) {
        HttpHeaders headers = new HttpHeaders();
        headers.add("Content-Type", "application/json; charset=utf-8");
        List<KnowledgeArea> result = KnowledgeArea.findByProfile(profileId);
        return new ResponseEntity<String>(KnowledgeArea.toJsonArray(result), headers, HttpStatus.OK);
    }
	
	@RequestMapping(value = "/getselectedknowledgeareasbyproject{projectId}", headers = "Accept=application/json")
    @ResponseBody
    public ResponseEntity<java.lang.String> findKnowledgeAreasByProjectJson(@PathVariable("projectId") long projectId) {
        HttpHeaders headers = new HttpHeaders();
        headers.add("Content-Type", "application/json; charset=utf-8");
        List<KnowledgeArea> result = KnowledgeArea.findByProject(projectId);
        return new ResponseEntity<String>(KnowledgeArea.toJsonArray(result), headers, HttpStatus.OK);
    }
}
